/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            staffDetailCommunitysInfo: {
                communitys: [],
                staffId: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('staffDetailCommunitys', 'switch', function (_data) {
                $that.staffDetailCommunitysInfo.staffId = _data.staffId;
                $that._loadStaffDetailCommunitysData(DEFAULT_PAGE, DEFAULT_ROWS)
            });
            vc.on('staffDetailCommunitys', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    vc.component._loadStaffDetailCommunitysData(_currentPage, DEFAULT_ROWS);
                });
            vc.on('staffDetailCommunitys', 'notify', function (_data) {
                $that._loadStaffDetailCommunitysData(DEFAULT_PAGE, DEFAULT_ROWS);
            })
        },
        methods: {
            _loadStaffDetailCommunitysData: function (_page, _row) {
                let param = {
                    params: {
                        staffId: $that.staffDetailCommunitysInfo.staffId,
                        page: _page,
                        row: _row
                    }
                };
                //发送get请求
                vc.http.apiGet('/role.listStaffCommunity',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.staffDetailCommunitysInfo.communitys = _json.data;
                        vc.emit('staffDetailCommunitys', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _qureyStaffDetailCommunitys: function () {
                $that._loadStaffDetailCommunitysData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openAddStaffCommunityModal:function(){
                vc.emit('addStaffCommunity', 'openAddStaffCommunityModal',{
                    staffId:$that.staffDetailCommunitysInfo.staffId,
                })
            },
            _openDeleteRoleCommunityModel:function(staffCommunity){
                vc.emit( 'deleteStaffCommunity','openDeleteStaffCommunityModal',staffCommunity)
            },
           
        }
    });
})(window.vc);